######################################################
##
##  TestLevels:
##
##  A few rooms with scripts intended to test
##  the CleanSweep engine and demonstrate
##  mapping style.
##
######################################################

:ref center-hallway
:ref right-hallway
:ref down-hallway
:ref closet

######################################################
##
##  Main room:
##
######################################################

:data grid-center-hallway
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40 1073741864 1073741864  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  -1 
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40 1073741864 1073741864  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  -1 
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40 1073741864 1073741864  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  -1 
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40 1073741864 1073741864  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  -1 
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40 1073741864 1073741864  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  -1 
	 40  40  40  11  11  11  10  10  41  10  10  10  10  10  10  10  10  10  10 1073741936 1073741937  10  10  10  10  10 114 115  10  10  10  40  40  11  11  11  10  10  10  10  -1 
	 40  40  40  11  11  11  10  10  10  10  10  10  10  10  10  10  10  10 127 1073741952 1073741953  10  10  10  10  10 130 131  10  44  10  40  40  11  11  11  83  84  10  10  -1 
	 40  40  40 116  11  11  10  10  10  10  10  10  10  10  10  10  10  10 127  -1  -1 147 148  10  10  10 132 133  10  10 127  40  40 116  11  11  99 100  10  10  -1 
	 40  40  40 132  45  11 127 127  11  11  11  11  10  10  10  10  10  10  42  -1  -1 163 164  10  10  42  75  76  10 127 127  40  40 132  11  11 127  10  10  10  -1 
	 40  40  40  75  61  59  60  46  47  46  47  59  60  43  60  60  60  60  60  -1  -1  60  60  60  60  60  40  40  60  60  60  40  40  75  59  59  60  60  43  60  -1 
	 40  40  40  18  77  18   0  62  63  62  63  18   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  40  40  18  18  18   0   0   0  16   0 
	 40  40  40  18  18  18   0  78  79  78  79  20   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  10  10  18  18  18   0   0   0  16   0 
	 40  40  40  18  18  18   0   2   2   2   2   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  10 127  18  18  20   0   0   0  16   0 
	 40  40  40  18  18  18   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 127  10  18  20   0   0   0   0  16   0 
	 40  40  40  18  18  18   0   0   0   0   0   0   0   0   0   0   1   0   0   0   0   0   0   0   0   0   0   0   0   0   0 127  10  20   0   0   0   0   0  16   0 
	 40  40  40  18  19  18   0   0   0   0   0   0   0   0   0   0   0   0   1   0   1   0   0   0   3   0   0   0   0   0   0  60  60   0   0   0   0   0   0  16   0 
	 40  40  40  19  19  19   0   0   0   0   0   0   0   0   0   3   5   7   1   5   5   0   3   7   7   5   0   1   0   0   0  16  16   0   0   0   0   0   0  16   0 
	 40  40  40  18  19  18   7   0   0   0   0   0   0   1   5   1   7   1   0   0   0   7   0   0   0   7   0   0   0   0   0  16  17   0   0   0   0   0   0  16   0 
	 40  40  40  18  18  18   0   0   0   0  18  19  18  19   0   0   0   0   3   0   0   0   0   0   0   0   0   0   0   0   0  16  17   0   0   0   0   0   0  16   0 
	 40  40  40  18  18  18   0   0   0 1073741942 1073741943 1073741942 1073741943  19   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 1073741895 1073741895   0   0   0   0   0   0  16   0 
	 40  40  40  18  18  18   0   0   0  62  63  62  63  18   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  40  40   0   0   0   0   0   0  16   0 
	 40  40  40  18  18  18   0 1073741942 1073741943 1073741942 1073741943  78  79  20   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  40  40   0   0   0   0   0   0  16   0 
	 40  40  40  18  18  18   0 1073741886 1073741887 1073741886 1073741887  18  18   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  40  40  18   0   0   0   0   0  16   0 
	 40  40  40 1073741895 1073741895 1073741895 1073741895  40  40  40  40 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895   0   0   0   0   0   0   0   0   0   0   0   0 1073741895 1073741895  40  40 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895   0 
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  40  40  40  40  40  40  40  40  40  -1 
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  40  40  40  40  40  40  40  40  40  -1 
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  40  40  40  40  40  40  40  40  40  -1 
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  40  40  40  40  40  40  40  40  40  -1 
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  40  40  40  40  40  40  40  40  40  -1 
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  40  40  40  40  40  40  40  40  40  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1   0   0   0   0   0   0   0   0   0   0   0   0  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 

: janet-tick ( id -- )
	>r
	i timer @ if
		i timer dec@
	else
		i flip-horiz
		300 random 200 + i timer !
	then
	rdrop
;

: janet-talk ( id -- )
	>r
	i face-player
	18 i tile!
	dialog-open
	dialog[
		"Shouldn't you be, like,"
		"cleaning or something?"
	]-text
	20 i tile!
	dialog[
		"Tee hee hee!"
	]-text
	dialog-close
	16 i tile!
	rdrop
;

: init-center-hallway
	0 GS ! grid-center-hallway GP !
	closet 19 6 spawn-door
	8 14 spawn-scrubby
	20 16 16 ' janet-tick ' janet-talk spawn-npc drop
;

: main-center-hallway
	loop
		main-common
	again
;

:data center-hallway
	init-center-hallway
	main-center-hallway
	0 right-hallway down-hallway 0

######################################################
##
##  Right hallway:
##
######################################################

:data grid-right-hallway
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  -1  -1  -1  -1 
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  -1  -1  -1  -1 
	 10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  40  40  -1  -1  -1  -1 
	 10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  83  84  10  10  10  10  10  10  10  10  10  40  40  -1  -1  -1  -1 
	 10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  99 100  10  10  10  10  42  10  10  10  10  40  40  -1  -1  -1  -1 
	 10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10  10 127  10  10  10  10  10  10  10  10  10  10  10  10  40  40  -1  -1  -1  -1 
	 60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  60  43  60  60  60  60  60  59  60  60  60  60  60  60  60  60  60  60  60  60  40  40  -1  -1  -1  -1 
	  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  18  18  18   0   0   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1 
	  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  36  18  18   0   0   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1 
	  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1 
	  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1 
	  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0 1073741942 1073741943   0   0   0   0  40  40  -1  -1  -1  -1 
	  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  62  63  38   0   0   0  40  40  -1  -1  -1  -1 
	  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  78  79  18   0   0   0  40  40  -1  -1  -1  -1 
	  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  36  18  18   0   0   0  40  40  -1  -1  -1  -1 
	  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1 
	  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1 
	  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1 
	  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1 
	  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1 
	1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895  40  40  -1  -1  -1  -1 
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  -1  -1  -1  -1 
	 40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 

:var right-garbage

: init-right-hallway
	0 GS ! grid-right-hallway GP !
	 8 14 22 { drop } 0 spawn-npc drop
	right-garbage 20 10 spawn-garbage-can
;

: main-right-hallway
	loop
		main-common
	again
;

:data right-hallway
	init-right-hallway
	main-right-hallway
	0 0 0 center-hallway

######################################################
##
##  Lower hallway:
##
######################################################

:data grid-down-hallway
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  19  19  16  16  16  16  16  16  16  16  16  16  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1

: init-down-hallway
	0 GS ! grid-down-hallway GP !
	21 16 spawn-puddle
;

: main-down-hallway
	loop
		main-common
	again
;

:data down-hallway
	init-down-hallway
	main-down-hallway
	center-hallway 0 0 0

######################################################
##
##  Utility Closet:
##
######################################################

:data grid-closet
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  40  40  40  40  40  40 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864  40  40  40  40  40  40  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  40  40  40  40  40  40 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864  40  40  40  40  40  40  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  10  10  10  10  10 134 1073741952 1073741953 1073741959 1073741958 1073741952 1073741953 1073741959 1073741958 1073741952 1073741953 135  10  10  10  10  10  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  10  10  10  10  10  10  10 134 1073741952 1073741953 135 134 1073741952 1073741953 135  10  10  10  10  10  10  10  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  60  60  60  60  60 127  10  10 127  60  60  60  60 127  10  10 127  60  60  60  60  60  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40 149 150 150 150 151  75  60  60  76 149 150 150 150  75  60  60  76 149 150 150 150 151  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  88  89  89  89  90  18  18  18  18  88  89  89  90  18  18  18  18  88  89  89  89  90  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  88  73  89  89  90  18   8   8  18  88  90  88  90  18   8   8  18  88  73  73  89  90  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  88  89  73  73  90  18   8   8   0  36  18  18  18  18   8   8   0  88  29  29  73  90  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  72  73  73  73  74  18   0   0   0   2   2   2   2   2   0   0   0  72  73  73  73  74  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  18  18  18  18  18  18   0   0   0   2   2   2   2   0   0   0   0  36  18  18  18  18  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  18  18   0   0   0   0   0   0   0   2   2   0   0   0   0   0   0   0   0   0   0   0  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40 1073741973 1073741974 1073741974 1073741975 1073741973 1073741974 1073741974 1073741975   2   2   2   0   0   0 1073741973 1073741974 1073741974 1073741975 1073741973 1073741974 1073741974 1073741975  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  88  89  89  90  88  89  89  90   2   2   2   0   0   0  88  89  89  90  88  89  89  90  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  88  89  73  90  88  29  89  90   2   2   2   2   2   2  88  73  89  90  88  89  89  90  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  88  89  73  90  88  89  73  90  18   2   2   2   2   2  88  89  73  90  88  89  73  90  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  72  73  73  74  72  73  73  74  18   2   2   2   2   2  72  73  73  74  72  73  73  74  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  18  18  18  18  18  18  18  18  18   2   2   2   2   2  36  18  18  18  18  18  18  18  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  18  18   2   2   2   2   2   2   2  16  16  16  16   2   2   2   2   2   2   2   2   2  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895  16  16  16  16 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895 1073741895  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  40  40  40  40  40  40  40  40  40  40  40 1073741895 1073741895 1073741895 1073741895  40  40  40  40  40  40  40  40  40  40  40  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  40  40  40  40  40  40  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 
	 -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1  -1 

:data bob-delta
-1 -1 -2 -1 0 0 0
 1  1  2  1 0 0 0

: bob ( id -- )
	>r
	i timer inc@
	i timer @ 8 mod -if
		i prev @ bob-delta + @
		dup 0 < if 60 else 59 then i tile!
		i +py
		i prev @ 1 + 14 mod i prev !
	then
	rdrop
;

: follow ( id -- )
	>r
	i px 16 - player @ px over 32 + within if
		61 i tile!
	else
		62 i tile!
		player @ px i px < if
			i face-left
		else
			i face-right
		then
	then
	rdrop
;

#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

:var follower
: access ( id -- )
	>r
	' follow instance follower !
	63 follower @ tile!
	dialog-open
	dialog[
		"<Greetings, Comrade."
		"Would you like me to brief you on"
		"available cleaning equipment?>"
	]-ask
	if
		62 follower @ tile!
		player   @ face-left
		follower @ face-left
		dialog[
			"<To the left are dessicant powder"
			"canisters. They can be used to soak"
			"up spills, but leaves a residue.>"
		]-text
		player   @ face-right
		follower @ face-right
		dialog[
			"<To the right are absorbent mats."
			"Place them in areas of high foot-"
			"traffic to stop the spread of dirt.>"
		]-text
	else
		61 follower @ tile!
		dialog[ "<Very well, then, Comrade.>" ]-text
	then
	
	63 follower @ tile!
	dialog[ "<Good cleaning to you!>" ]-text
	dialog-close
	rdrop
;

: spawn-items ( -- )
	' powder any? -if
		15 7 spawn-powder
	then
	' mat any? -if
		23 7 spawn-mat
	then
;

: init-closet
	' spawn-items ' resupply revector
	spawn-items

	0 GS ! grid-closet GP !
	19 16 spawn-scrubby
	48x16 19 20 spawn-exit-door

	15 3 60 ' bob 0 spawn-npc 10 swap timer !
	23 3 60 ' bob 0 spawn-npc  2 swap prev  !
	17 3 59 ' bob 0 spawn-npc  3 swap prev  !
	21 3 59 ' bob 0 spawn-npc  7 swap prev  !
	19 4 61 ' follow 0 spawn-npc drop
	19 6 0 { drop } ' access spawn-npc hide
;

: main-closet
	loop
		main-common
	again
;

:data closet
	init-closet
	main-closet
	0 0 0 0

######################################################
##
##  Global initialization:
##
######################################################

: init-testlevels ( -- )
	GP @ GS @

	0 GS ! grid-right-hallway GP !
	1 11 32 10 soil
	RN @ 3 mod 1 + right-garbage !

	GS ! GP !
;